/*
 集合
 一组互不相同的实例的无序组合。（元素唯一）（无序）
 */
import Cocoa

//1.创建集合
var groceryBad = Set<String>()
groceryBad.insert("Apples")
groceryBad.insert("Oranges")
groceryBad.insert("Pineapple")
var groceryBad1:Set = ["Bananas","Cereal","Milk","Oranges"]

//2.遍历集合
for food in groceryBad {
    print(food)
}

//3.运用集合
let hasBananas = groceryBad.contains("Bananas")

let commonGroceryBad = groceryBad.union(groceryBad1)    //并集，会去除重复的部分

let items = groceryBad.intersection(groceryBad1)        //交集

let disjoint = groceryBad.isDisjoint(with: groceryBad1)     //不想交，如果为真，说明两个集合没有相同的，如果为假，说明有相同的元素
